using System;
using ThirdLife.UI.WinForms.Controls;

namespace ThirdLife.UI.WinForms.Modules
{
  public class AboutBoxUIModule : IUIModule, IAboutBoxController
  {
    private IUIModuleServices _moduleServices;
    private TLAboutBox _aboutBox;
    private TLAboutBoxContributors _aboutBoxContributors;
    private TLAboutBoxLicense _aboutBoxLicense;

    #region IUIModule Members

    public IUIModuleServices ModuleServices
    {
      get { return _moduleServices; }
      set { _moduleServices = value; }
    }

    public string Name
    {
      get { return "ThirdLife_AboutBox"; }
    }

    public void Setup()
    {
      ModuleServices.Startup.ApplicationStarted += Startup_ApplicationStarted;
    }

    #endregion

    private void Startup_ApplicationStarted()
    {
      //we probbly want this to be the last menu
      ModuleServices.Registration.AddMenu("Help", 10000);
      //we probably always want this to be last
      ModuleServices.Registration.AddMenuItem("Help", "About", 10000, new EventHandler(OnAboutRequested));
    }

    private void OnAboutRequested(object sender, EventArgs e)
    {
      _aboutBox = new TLAboutBox();
      _aboutBox.Controller = this as IAboutBoxController;
      _aboutBox.SetupView();
      _aboutBox.ShowWindow();
    }

    public void ShowContributors()
    {
      _aboutBoxContributors = new TLAboutBoxContributors();
      _aboutBoxContributors.Controller = this as IAboutBoxController;
      _aboutBoxContributors.SetupView();
      _aboutBoxContributors.ShowWindow();
    }

    public void ShowLicense()
    {
      _aboutBoxLicense = new TLAboutBoxLicense();
      _aboutBoxLicense.Controller = this as IAboutBoxController;
      _aboutBoxLicense.SetupView();
      _aboutBoxLicense.ShowWindow();
    }
  }
}